import Mock from 'mockjs'
var Random = Mock.Random

// 登录
const userList = {
    data: {
        total: 2,
        userInfo: [{
            userName: 'admin',
            password: 'admin',
            job: 'admin',
            token: '000111222333444555666',
            id: '100'
        }, {
            userName: 'editor',
            password: 'admin',
            job: 'editor',
            token: '666555444333222111',
            id: '101'
        }],
        mate: 200,
        message: 'success'
    }
}

Mock.mock('/mock/api/user', 'post', options => {
    const { userName, password } = JSON.parse(options.body)
    for (let i = 0; i< userList.data.userInfo.length; i++) {
        // 判断userName and password
        if (userName === userList.data.userInfo[i].userName && password === userList.data.userInfo[i].password) {
            return {
                mate: {
                    message: 'success',
                    status: 200
                },
                result: {
                    userName: userList.data.userInfo[i].userName,
                    token: userList.data.userInfo[i].token,
                    id: userList.data.userInfo[i].id,
                    job: userList.data.userInfo[i].job
                }
            }
        }
    }
    return {
        mate: {
            message: '用户不存在',
            status: 201
        }
    }
})
// sider
const navList = {
    data: {
        status: 200,
        result: [{
            name: '首页',
            id: 1,
            path: '/home',
            icon: 'BankFilled'
        }, {
            name: '权限管理',
            id: 2,
            path: '/power',
            icon: 'SettingFilled'
        }, {
            name: '人员管理',
            id: 8,
            path: '/people',
            icon: 'SettingFilled',
            children: [{
                name: 'VIP管理',
                id: 8.1,
                path: '/viper'
            }, {
                name: '员工管理',
                id: 8.2,
                path: '/staff'
            }]
        }, {
            name: '仓储管理',
            id: 3,
            path: '/stock',
            icon: 'ShopFilled',
            children: [{
                name: '仓库管理',
                id: 3.0,
                path: '/warehouse',
            }, {
                name: '出库管理',
                id: 3.1,
                path: '/',
            }, {
                name: '入库管理',
                id: 3.2,
                path: '/'
            }, {
                name: '库存管理',
                id: 3.3,
                path: '/'
            }, {
                name: '报废列表',
                id: 3.4,
                path: '/'
            }]
        }, {
            name: '退补货管理',
            id: 4,
            // path: '/',
            icon: 'AppstoreFilled',
            children: [{
                name: '退货',
                path: '/',
                id: 4.1
            }, {
                name: '采购订单',
                path: '/purchasing',
                id: 4.2
            }]
        }, {
            name: '财务报表',
            path: '/',
            id: 5,
            icon: 'FundFilled',
            children: [{
                name: '季度报表',
                path: '/',
                id: 5.1
            }, {
                name: '月度报表',
                path: '/',
                id: 5.2
            }, {
                name: '年度报表',
                path: '/',
                id: 5.3
            }]
        }, {
            name: '采购单管理',
            path: '/',
            id: 6,
            icon: 'ContainerFilled'
        }, {
            name: '经营管理',
            path: '/',
            id: 7,
            icon: 'CalculatorFilled'
        }]
    }
}

Mock.mock('/mock/api/navList', 'get', () => {
    return navList
})


/*
数据总览:
    * name: 模块名称
    * count: 数量
    * icon: 图标名称
*/
const getHomeData = {
    status: 200,
    result: [{
        name: '会员人数',
        count: 100215,
        icon: 'RobotFilled'
    }, {
        name: '补货通知',
        count: 12,
        icon: 'BellFilled'
    }, {
        name: '今日营业额',
        count: 5321,
        icon: 'AccountBookFilled'
    }, {
        name: '今日采购额',
        count: 3541,
        icon: 'ShopFilled'
    }]
}

Mock.mock('/mock/api/allData', 'get', () => {
    return getHomeData
})

// 首页折线图
const contrast = {
    status: 200,
    result: [
        {
            name: 'reality',
            data: [
                {
                    date: '周一',
                    data: 30
                }, {
                    date: '周二',
                    data: 22
                }, {
                    date: '周三',
                    data:  45
                }, {
                    date: '周四',
                    data: 35
                }, {
                    date: '周五',
                    data: 22
                }, {
                    date: '周六',
                    data: 86
                }, {
                    date: '周日',
                    data: 59
                }
            ]
        },
        {
            name: 'calculate',
            data: [
                {
                    date: '周一',
                    data: 40
                }, {
                    date: '周二',
                    data: 55
                }, {
                    date: '周三',
                    data: 34
                }, {
                    date: '周四',
                    data: 60
                }, {
                    date: '周五',
                    data: 57
                }, {
                    date: '周六',
                    data: 38
                }, {
                    date: '周日',
                    data: 20
                },
            ]
        }
    ]
}

Mock.mock('/mock/api/contrast', 'get', () => {
    return contrast
})

/*
    * id: 编号
    * name: 姓名
    * age: 年龄
    * dept: 部门
    * baseWage: 基本工资
    * num: 销售数量
    * houns: 提成
*/
const salesManList = {
    status: 200,
    result: [{
            id: 12138,
            name: '王力宏',
            age: 45,
            dept: ['洗发水销售'],
            baseWage: 4000,
            num: 60,
            houns: 600
        }, {
            id: 12139,
            name: '吴亦凡',
            age: 46,
            dept: ['缝纫机销售'],
            baseWage: 4700,
            num: 50,
            houns: 500
        }, {
            id: 12140,
            name: '华强',
            age: '+∞',
            dept: ['西瓜销售'],
            baseWage: 3000,
            num: 9999,
            houns: 99990
        }, {
            id: 12141,
            name: '大漠',
            age: 48,
            dept: ['散养土鸡销售'],
            baseWage: 4000,
            num: 800,
            houns: 8000
        }, {
            id: 12142,
            name: '吴宪',
            age: 45,
            dept: ['代步工具销售'],
            baseWage: 6000,
            num: 10,
            houns: 1000
        }]
}

Mock.mock('/mock/api/sales', 'get', () => {
    return salesManList
})

/*
    * id: 商品id,
    * name: 商品大分类,
    * price: 商品月销售额，
    * static：是否缺货
*/
const waresList = {
    status: 200,
    result: [{
        id: 5472,
        name: '杯子',
        price: 1564,
        static: ['充足']
    }, {
        id: 1812,
        name: '家居用品',
        price: 7814,
        static: ['充足']
    }, {
        id: 5587,
        name: '电饭煲',
        price: 9781,
        static: ['充足']
    }, {
        id: 7514,
        name: '猪肉',
        price: 15900,
        static: ['缺货']
    }, {
        id: 7031,
        name: '零食',
        price: 7808,
        static: ['待补货']
    }, {
        id: 3167,
        name: '体育用品',
        price: 8708,
        static: ['待补货']
    }, {
        id: 9841,
        name: '玩具',
        price: 19045,
        static: ['缺货']
    }, {
        id: 2318,
        name: '饮食',
        price: 5725,
        static: ['充足']
    }]
}

Mock.mock('/mock/api/wares', 'get', () => {
    return waresList
})

/**
 * name: 姓名,
 * id: 编号,
 * avatar: 头像，
 * message: 留言类容,
 * dept: 销售部门,
 * time: 留言时间
 */
const messageBoard = {
    status: 200,
    result: [{
        name: '华强',
        id: 12138,
        avatar: 'http://192.168.10.129:8080/img/liu.d7a00ac8.png',
        message: '你这瓜保不保熟啊',
        dept: '西瓜销售组',
        time: '9小时前'
    },{
        name: '瓜主',
        id: 48418,
        avatar: 'http://192.168.10.129:8080/img/gua.3622ad6a.png',
        message: '我能卖你生瓜蛋子？',
        dept: '西瓜销售组',
        time: '9小时前'
    },{
        name: '西瓜销售组组长',
        id: 54891,
        avatar: 'http://192.168.10.129:8080/img/boss.bc0ae98f.png',
        message: '别劈瓜了，都缺货了',
        dept: '西瓜销售组',
        time: '9小时前'
    },{
        name: '零食销售甲',
        id: 154836,
        avatar: 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2FJyV8oP1xFXm14T8DN3DMrmKcTzmHsy4jGUc%3DtLAScMxMK1535179650243compressflag.jpg&thumbnail=650x2147483647&quality=80&type=jpg',
        message: '买花生，瓜子，香烟，火柴，口香糖咯',
        dept: '零食销售组',
        time: '9小时前'
    },{
        name: '华强',
        id: 12138,
        avatar: 'http://192.168.10.129:8080/img/liu.d7a00ac8.png',
        message: '你这零食保熟吗？',
        dept: '西瓜销售组',
        time: '9小时前'
    },{
        name: '零食销售甲',
        id: 154836,
        avatar: 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2FJyV8oP1xFXm14T8DN3DMrmKcTzmHsy4jGUc%3DtLAScMxMK1535179650243compressflag.jpg&thumbnail=650x2147483647&quality=80&type=jpg',
        message: '？？？？？？？？？？',
        dept: '零食销售组',
        time: '9小时前'
    },{
        name: '外卖员甲',
        id: 4891215,
        avatar: 'http://192.168.10.129:8080/img/shen.23686ec1.png',
        message: '我劈了你能咋地，你过来啊！',
        dept: '外卖组',
        time: '9小时前'
    },{
        name: '零食销售甲',
        id: 154836,
        avatar: 'http://192.168.10.129:8080/img/da.c9f2cf8d.png',
        message: '欸我过来啦，我又回来啦，打我啊笨蛋',
        dept: '沙包组',
        time: '9小时前'
    }]
}

Mock.mock('/mock/api/message', 'get', () => {
    return messageBoard
})
/**
 * title: 姓名
 * avatar: 头像
 * description: 消息类型和时间
 * content: 留言类容
 */
Mock.mock('/mock/api/userMessage', 'get', {
     status: 200,
    'result|4-5': [{
        'title|1': [
            'Iron Man',
            'Captain American',
            'Spider Man'
        ], 
        'avatar|1': [
            'https://wpimg.wallstcn.com/57ed425a-c71e-4201-9428-68760c0537c4.jpg?imageView2/1/w/80/h/80',
            'https://wpimg.wallstcn.com/9e2a5d0a-bd5b-457f-ac8e-86554616c87b.jpg?imageView2/1/w/80/h/80',
            'https://wpimg.wallstcn.com/fb57f689-e1ab-443c-af12-8d4066e202e2.jpg?imageView2/1/w/80/h/80'
        ] ,
        'description|1': [
            '公开回复 - 7:30 PM 今天',
            '私信 - 昨天',
            '来自关心: 发布了4张照片 - 2天前'
        ],
        'content|1': [
            '改造一切的东西，上班不迟到才是真的',
            '别信老钢的， 他就是想卷死你',
            '改造一切的东西，上班不迟到才是真的'
        ]
    }]
})


// 时间线
Mock.mock('/mock/api/timeLine', 'get',  {
    status: 200,
    'result|4-6': [{
        timer: Random.date('yyyy-MM-dd'),
        'timer|1': [
            Random.time('A HH:mm:ss'),
            Random.time('A HH:mm:ss'),
            Random.time('A HH:mm:ss'),
            Random.time('A HH:mm:ss'),
        ],
        'local|1': [
            '高新分店',
            '犀浦分店',
            '国外分店'
        ],
        'mins|1': [
            Mock.mock('@date'),
            Mock.mock('@date'),
            Mock.mock('@date'),
            Mock.mock('@date'),
        ]
    }]
})

const overDue = {
    status: 200,
    'result': [{
        'name': Random.csentence(3, 5), 
        'isOverdue': '2',
        'id': 1
    },{
        'name': Random.csentence(3, 5), 
        'isOverdue': '1',
        'id': 2
    },{
        'name': Random.csentence(3, 5), 
        'isOverdue': '2',
        'id': 3
    },{
        'name': Random.csentence(3, 5), 
        'isOverdue': '2',
        'id': 4
    },{
        'name': Random.csentence(3, 5), 
        'isOverdue': '2',
        'id': 5
    },{
        'name': Random.csentence(3, 5), 
        'isOverdue': '1',
        'id': 6
    },{
        'name': Random.csentence(3, 5), 
        'isOverdue': '1',
        'id': 7
    },{
        'name': Random.csentence(3, 5), 
        'isOverdue': '1',
        'id': 8
    },{
        'name': Random.csentence(3, 5), 
        'isOverdue': '2',
        'id': 9
    },{
        'name': Random.csentence(3, 5), 
        'isOverdue': '1',
        'id': 10
    }]
}

// 临期过期表
Mock.mock('/mock/api/overdue', 'get', overDue)

// 根据id删除
Mock.mock('/mock/api/del', 'post', option => {
    const { id } = JSON.parse(option.body)
    const overDelList = overDue.result.filter(item => item.id * 1 !== id * 1)
    return {
        status: 200,
        overDelList
    }
})

/**
 * 权限管理-人员表
 * @author xiaoYu
 * @date
 */

let powerList = {
    status: 200,
    result: [{
            id: 12138,
            job: 'admin',
            name: '王力宏',
            age: 45,
            dept: '洗发水销售',
            baseWage: 4000,
            num: 60,
            houns: 600,
            upDataTime: '2021-01-04'
        }, {
            id: 12139,
            name: '吴亦凡',
            job: 'admin',
            age: 46,
            dept: '缝纫机销售',
            baseWage: 4700,
            num: 50,
            upDataTime: '2021-01-05',
            houns: 500
        }, {
            id: 12140,
            name: '华强',
            job: 'admin',
            age: '+∞',
            dept: '西瓜销售',
            baseWage: 3000,
            num: 9999,
            upDataTime: '2021-01-06',
            houns: 99990
        }, {
            id: 12141,
            name: '大漠',
            job: 'editor',
            age: 48,
            dept: '散养土鸡销售',
            baseWage: 4000,
            num: 800,
            upDataTime: '2021-01-07',
            houns: 8000
        }, {
            id: 12142,
            name: '吴宪',
            job: 'editor',
            age: 45,
            upDataTime: '2021-01-08',
            dept: '代步工具销售',
            baseWage: 6000,
            num: 10,
            houns: 1000
        }]
}

Mock.mock('/mock/api/powerPeople', 'get', () => {
    return powerList
})

/**
 * 权限管理-修改
 * @author xiaoYu
 * @date
 */

Mock.mock('/mock/api/powerEdit', 'post', options => {
    const { baseWage, job, id } = JSON.parse(options.body)
    for(let i = 0; i < powerList.result.length; i++) {
        if (id === powerList.result[i].id) {
            powerList.result[i].baseWage = baseWage
            powerList.result[i].job = job
            return {
                mate: {
                    message: 'success',
                    status: 200
                },
                data: null,
                message: '请求成功'
            }
        }
    }
})

/**
 * 权限管理-删除
 * @author xiaoYu
 * @date
 */

Mock.mock('/mock/api/powerDel', 'post', options => {
    const { id } = JSON.parse(options.body)
    powerList.result = powerList.result.filter(item => id !== item.id)
})

/**
* @author xiaoYu
* @date 
* name: 商品名称
* supplier: 供应商
* upDate: 预计到货时间
* amountPaid: 已付金额
* amount: 总金额
* status: 采购单状态 
*/
Mock.mock('/mock/api/purchasingOrder', 'get', {
   status: 200,
   result: [{
       name: '采购项1',
       supplier: '供应商1',
       upDate: '2022-01-06',
       mark: '测试消息1',
       amount: '999',
       amountPaid: '1000',
       status: 1,
       transport: '待发货'
   }]
})

/**
 * 仓库管理列表查询
 * @author xiaoYu
 * @date
 */
Mock.mock('/mock/api/warehousePage', 'get', {
    status: 200,
    result: [{
        name: '仓库1',
        id: '745154',
        code: 'CK1',
        address: '天河路32号仓',
        size: '900件',
        createDate: '2022-01-15 10:43',
        upDate: ''
    }, {
        name: '仓库2',
        id: '4482318',
        code: 'CK2',
        address: '天河路33号仓',
        size: '900件',
        createDate: '2022-01-16 10:44',
        upDate: ''
    }, {
        name: '仓库2',
        id: '4482318',
        code: 'CK2',
        address: '天河路33号仓',
        size: '900件',
        createDate: '2022-01-16 10:44',
        upDate: ''
    }, {
        name: '仓库3',
        id: '4565121',
        code: 'CK3',
        address: '天河路34号仓',
        size: '900件',
        createDate: '2022-01-16 10:44',
        upDate: ''
    }, {
        name: '仓库4',
        id: '879870',
        code: 'CK4',
        address: '天河路35号仓',
        size: '900件',
        createDate: '2022-01-16 10:44',
        upDate: ''
    }]
})

/**
 * vip人员查询
 * @author xiaoYu
 * @date
 */
Mock.mock('/mock/api/peopleForViper', 'get', {
    status: 200,
    result: [{
        name: Mock.mock('@cname'),
        sex: '男',
        phone: Random.natural(),
        cardId: Random.float(0),
        integration: Random.integer(0, 500)
    }, {
        name: Mock.mock('@cname'),
        sex: '女',
        phone: Random.natural(),
        cardId: Random.float(0),
        integration: Random.integer(0, 500)
    }, {
        name: Mock.mock('@cname'),
        sex: '女',
        phone: Random.natural(),
        cardId: Random.float(0),
        integration: Random.integer(0, 500)
    }, {
        name: Mock.mock('@cname'),
        sex: '男',
        phone: Random.natural(),
        cardId: Random.float(0),
        integration: Random.integer(0, 500)
    }, {
        name: Mock.mock('@cname'),
        sex: '男',
        phone: Random.natural(),
        cardId: Random.float(0),
        integration: Random.integer(0, 500)
    }]
})











